package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpHRSkillMaintenanceDetailPageUtil extends SeleniumPageUtil {
	public final static By SMD_IMG_EDIT = By.xpath("//*[@id='ctl44_SkillMaintenanceReport_ReportOutput']/table/tbody");
	
	public final static By SMD_SPAN_HEADER = By.id("ctl44_hdrSkillMaintenance_lblHeader");
	public final static By SMD_LINK_SAVE = By.xpath("//*[@id='0790172a-861a-45e1-a408-ef42dcc1dcb3']/a");
	public final static By SMD_LINK_CLOSE = By.xpath("//*[@id='3cf044f9-6c2e-4ab3-aeee-5af093c46053']/a");
	public final static By SMD_TD_CATEGORY = By.xpath("//*[@id='dvMaintItemEdit']/table[2]/tbody/tr[1]/td[1]");
	public final static By SMD_INPUT_CATEGORY = By.id("ctl44_txtCategory");
	public final static By SMD_TD_SUB_CATEGORY = By.xpath("//*[@id='trSubCategory']/td[1]");
	public final static By SMD_INPUT_SUB_CATEGORY = By.id("ctl44_txtSubCategory");
	public final static By SMD_TD_SKILL = By.xpath("//*[@id='trSkill']/td[1]");
	public final static By SMD_INPUT_SKILL = By.id("ctl44_txtSkill");
	
	public static void enterMaintenanceEditDetailPage(){
		SpHRSkillMaintenancePageUtil.enterHRSkillMaintenancePage();
		SeleniumUtil.click(SeleniumUtil.findElements(SeleniumUtil.findElement(SMD_IMG_EDIT),By.xpath("//img[@title='Edit']")).get(0));
		waitForPageToLoad();
	}
	
	public static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				SMD_IMG_EDIT, SMD_LINK_SAVE, SMD_LINK_CLOSE
			});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(SMD_IMG_EDIT));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(SMD_LINK_SAVE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(SMD_LINK_CLOSE));
	}
}
